package com.greendragon.service.backend.impl; 

import java.util.List;

import com.greendragon.persistence.dao.ICommentDao;
import com.greendragon.persistence.domain.PageComment;
import com.greendragon.persistence.enmu.FetchOrderType;
import com.greendragon.service.backend.ICommentBackendService;

/** 
 * @author wulibin, exceptsky@gmail.com, 2011-12-6 下午07:01:27
 * 
 */
public class PageCommentBackendService extends BaseBackendService<PageComment> implements ICommentBackendService<PageComment>{
	private ICommentDao<PageComment> commentDao;
	
	@Override
	public long getCountOfUnVerified() {
		PageComment expComment = new PageComment();
		expComment.setVerified(false);
		expComment.setBlock(false);
		return commentDao.getCountByCondition(expComment);
	}

	@Override
	public long getCountOfVerified() {
		PageComment expComment = new PageComment();
		expComment.setVerified(true);
		expComment.setBlock(false);
		return commentDao.getCountByCondition(expComment);
	}
	
	@Override
	public long getCountOfLock() {
		PageComment expComment = new PageComment();
		expComment.setBlock(true);
		return commentDao.getCountByCondition(expComment);
	}

	@Override
	public List<PageComment> getUnVerified(int page) {
		PageComment expComment = new PageComment();
		expComment.setVerified(false);
		expComment.setBlock(false);
		return commentDao.getByCondition(expComment, page*pageLength, pageLength, FetchOrderType.CREATE_DESC);
	}

	@Override
	public List<PageComment> getVerified(int page) {
		PageComment expComment = new PageComment();
		expComment.setVerified(true);
		expComment.setBlock(false);
		return commentDao.getByCondition(expComment, page*pageLength, pageLength, FetchOrderType.CREATE_DESC);
	}

	public void setCommentDao(ICommentDao<PageComment> commentDao) {
		this.commentDao = commentDao;
		this.setDao(commentDao);
	}
}
 